package com.fjt.book_pay.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import com.fjt.book_pay.dao.P_RecordDao;
import com.fjt.book_pay.pojo.P_Record;
import com.fjt.book_pay.pojo.P_User;

@Service("p_recordservice")
public class P_RecordService {
	private P_RecordDao p_RecordDao;
	private P_Record p_Record;
	public P_RecordDao getP_RecordDao() {
		return p_RecordDao;
	}
	@Resource
	public void setP_RecordDao(P_RecordDao p_RecordDao) {
		this.p_RecordDao = p_RecordDao;
	}
	public P_Record getP_Record() {
		return p_Record;
	}
	@Resource(name="p_record")
	public void setP_Record(P_Record p_Record) {
		this.p_Record = p_Record;
	}
	
	public Map<String, Object> selectMyRecord(P_Record p_Record){
		Map<String, Object> map=new HashMap<String, Object>();
		P_Record p_record=p_RecordDao.selectMyRecord(p_Record);
		if(p_record!=null){
			map.put("code", 1);
			map.put("result", "查询成功！");
			map.put("recordInfo", p_record);
		}else{
			map.put("code", 0);
			map.put("result", "查询失败！");
		}
		return map;
	}
	
	public Map<String, Object> selectUserAllRecord(P_User user){
		Map<String, Object> map=new HashMap<String, Object>();
		List<P_Record> list=p_RecordDao.selectUserAllRecord(user.getPay_name());
		System.out.println(user.getPay_name());
		if(list!=null){
			map.put("code", 1);
			map.put("result", "查询成功！");
			map.put("recordlist", list);
		}else{
			map.put("code", 0);
			map.put("result", "查询失败！");
		}
		return map;
	}
	
	public boolean addRecord(P_Record p_Record){
		return p_RecordDao.addRecord(p_Record);
	}
}
